/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package business;

import dal.CarBookingDAL;
import java.util.ArrayList;
import java.util.List;
import model.CarBooking;

/**
 *
 * @author Nhang Con
 */
public class CarBookingBusiness {

    private CarBookingDAL carbookingDal = new CarBookingDAL();

    public List<CarBooking> getListBookingCar(int pageID) {
        List<CarBooking> lcar=carbookingDal.getListCarBooking();
         List<CarBooking> listCarByPage = new ArrayList<CarBooking>();
        for (int i = (pageID - 1) * 3; i < (pageID * 3); i++) {
            try {
                listCarByPage.add(lcar.get(i));
            } catch (IndexOutOfBoundsException e) {
                return listCarByPage;
            }
        }
        return listCarByPage;

        
    }
     public int getRowInListTour() {
        return carbookingDal.getListCarBooking().size();
    }

    public String getCarNameByID(int carid) {
        return carbookingDal.getCarName(carid);

    }
    private BankBusiness bankbusiness = new BankBusiness();

    public boolean updateStatusBooking(CarBooking carbooking) {
        if (carbookingDal.updateStatusCarBooking(carbooking.getCarBookingID())) {

            if (bankbusiness.reFundCar(carbooking.getCustomerID(), carbooking.getCarBookingID())) {
                return true;
            }
            return false;
        }
        return false;

    }
}
